package com.woniuxy.controller;

import com.woniuxy.service.PileService;
import com.woniuxy.util.PageParam;
import com.woniuxy.util.ResponseData;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RequestMapping("/pile")
@RestController
@AllArgsConstructor
public class PileController {
    private PileService pileService;
    @PostMapping("/queryAll")
    public ResponseData<?> queryAll(@RequestBody PageParam<?> pageParam) {
        return ResponseData.ok(pileService.queryAll(pageParam));
    }

    @PostMapping("/queryByStationId")
    public ResponseData<?> queryByStationId(@RequestBody PageParam<Long> pageParam) {
        return ResponseData.ok(pileService.queryByStationId(pageParam));
    }

    @PostMapping("/queryUnrelatedByStationId")
    public ResponseData<?> queryUnrelatedByStationId(@RequestBody PageParam<Long> pageParam) {
        return ResponseData.ok(pileService.queryUnrelatedByStationId(pageParam));
    }

    @PostMapping("/cancelRelation")
    public ResponseData<Void> cancelRelation(@RequestBody Map<String, Long> params) {
        pileService.cancelRelation(params.get("pileId"));
        return ResponseData.ok();
    }
    @PostMapping("/addRelation")
    public ResponseData<Void> addRelation(@RequestBody Map<String, Long> params) {
        pileService.addRelation(params.get("pileId"));
        return ResponseData.ok();
    }
}
